#! /usr/bin/python
# Copyright (C) 2010  Johan Jordaan (www.johanjordaan.co.za)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Todo List
#
class Mapper:
  ''' This sort of a ordered dictiorany '''
  def __init__(self,mapping):
    self.mapping = mapping
    self.key_arr = []
    self.value_arr = []
    for item in mapping:
      self.key_arr.append(item.keys()[0])
      self.value_arr.append(item[item.keys()[0]])
  def __getitem__(self,key):
    return self.value_arr[self.key_arr.index(key)]
  
  def key_for(self,value):
    return self.key_arr[self.value_arr.index(value)]
  def keys(self):
    return self.key_arr
  def values(self):
    return self.value_arr
